package clientGUI.userPanels;

import javax.swing.JPanel;

import clientGUI.userPanels.Controllers.EvaluatorSetDeadLineController;
import clientserver.Client;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JComboBox;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;

public class EvaluatorSetDeadLinePanel extends UPanel {
	private JLabel curdaylbl;
	private JLabel enddaylbl;
	private JComboBox daysCB;
	private EvaluatorSetDeadLineController controller;
	
	public EvaluatorSetDeadLinePanel( Client c,int rid) {
	super();
		controller= new EvaluatorSetDeadLineController(c, rid);
		setLayout(null);
		
		JLabel lblCurrentDay = new JLabel("Current Date:");
		lblCurrentDay.setBounds(92, 90, 67, 14);
		add(lblCurrentDay);
		
		curdaylbl = new JLabel(controller.getStartDate());
		curdaylbl.setBounds(197, 90, 103, 14);
		add(curdaylbl);
		
		JLabel lblDaysToComple = new JLabel("Days to Comple Evaluation:");
		lblDaysToComple.setBounds(60, 112, 132, 14);
		add(lblDaysToComple);
		
		daysCB = new JComboBox(controller.possibledaysindeadline);
		daysCB.setBounds(197, 109, 78, 20);
		daysCB.addActionListener(new ActionListener() {   // Combo box choose days in deadline  listener
			public void actionPerformed(ActionEvent arg0) {
				
			int i=Integer.valueOf((String) daysCB.getSelectedItem());
			controller.addDays(i);
			enddaylbl.setText(controller.getEndDate());
			}
		});
		add(daysCB);
		 
		 JLabel lblDayComplteStage = new JLabel("Date to End Work:");
		 lblDayComplteStage.setBounds(66, 134, 89, 14);
		 add(lblDayComplteStage);
		
		 enddaylbl= new JLabel(controller.getEndDate());
		 enddaylbl.setBounds(197, 134, 103, 14);
		add(enddaylbl);
		
		JButton btnSet = new JButton("Set");
		btnSet.setBounds(337, 108, 78, 23);
		btnSet.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				controller.updateDBdays();
			}
		});
		add(btnSet);
		
		JButton btnNewButton = new JButton("Main Menu");
		btnNewButton.setBounds(137, 159, 115, 23);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				myframe.SetMainUserPanel();
			}
		});
		add(btnNewButton);
		client=c;

	}

}
